//
//  DisplayCarNavigationBar.m
//  CarHome
//
//  Created by lanou3g on 15-4-28.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "DisplayCarNavigationBar.h"

@implementation DisplayCarNavigationBar
{
    NSInteger _tagStartNum;
    CGColorRef _colorref;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _tagStartNum = 100;
        _colorref = CGColorCreate(CGColorSpaceCreateDeviceRGB(),(CGFloat[]){ 84.31 / 255.0, 87.84 / 255.0, 87.84 / 255.0, .3 });
        self.backgroundColor = [UIColor whiteColor];
        [self addAllViews];
    }
    return self;
}

- (void)addAllViews {
    
    self.returnBtn = [self getButtonWithTitle:@"返回" frame:CGRectMake(0, 0, kWIDTH / 4., kBTN_HEIGHT)];
    [_returnBtn setBackgroundImage:[UIImage imageNamed:@"bar_btn_icon_returntext_white"] forState:UIControlStateNormal];
    [_returnBtn setBackgroundImage:[UIImage imageNamed:@"bar_btn_icon_returntext"] forState:UIControlStateHighlighted];
    [_returnBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [self addSubview:_returnBtn];
    
    self.summaryBtn = [self getButtonWithTitle:@"综述" frame:CGRectMake(kWIDTH / 4., 0, kWIDTH / 4., kBTN_HEIGHT)];
    [_summaryBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [self addSubview:_summaryBtn];
    
    self.pictureBtn = [self getButtonWithTitle:@"图片" frame:CGRectMake(kWIDTH / 4 * 2., 0, kWIDTH / 4., kBTN_HEIGHT)];
    [self addSubview:_pictureBtn];
    
    self.dealerBtn = [self getButtonWithTitle:@"经销商" frame:CGRectMake(kWIDTH / 4. * 3, 0, kWIDTH / 4., kBTN_HEIGHT)];
    [self addSubview:_dealerBtn];
    
    self.alibiBtn = [self getButtonWithTitle:@"口碑" frame:CGRectMake(0, kBTN_HEIGHT, kWIDTH / 4., kBTN_HEIGHT)];
    [self addSubview:_alibiBtn];
    
    self.explainBtn = [self getButtonWithTitle:@"资讯" frame:CGRectMake(kWIDTH / 4. * 1, kBTN_HEIGHT, kWIDTH / 4., kBTN_HEIGHT)];
    [self addSubview:_explainBtn];

    self.bbsBtn = [self getButtonWithTitle:@"论坛" frame:CGRectMake(kWIDTH / 4. * 2, kBTN_HEIGHT, kWIDTH / 4., kBTN_HEIGHT)];
    [self addSubview:_bbsBtn];
    
    self.newsBtn = [self getButtonWithTitle:@"详情" frame:CGRectMake(kWIDTH / 4. * 3, kBTN_HEIGHT, kWIDTH / 4., kBTN_HEIGHT)];
    [self addSubview:_newsBtn];
    
    self.labelRow1 = [[UILabel alloc] initWithFrame:CGRectMake(kWIDTH / 4, kBTN_HEIGHT - 1, kWIDTH / 4, 2)];
    _labelRow1.backgroundColor = [UIColor blueColor];
    [self addSubview:_labelRow1];
    
}

- (UIButton *)getButtonWithTitle:(NSString *)title frame:(CGRect)frame {
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
    [btn setTitle:title forState:UIControlStateNormal];
    btn.frame = frame;
    btn.titleLabel.font = [UIFont fontWithName:@"Arial" size:kBTN_FONT_SIZE];
    [btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    btn.backgroundColor = [UIColor whiteColor];
    [btn.layer setBorderWidth:.25];   //边框宽度
    [btn.layer setBorderColor:_colorref];//边框颜色
    [btn setTag:_tagStartNum++];
    
    return btn;
}




@end
